package com.qiwx.pigeon.adapter.query;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.Utils.DBSqlUtil;
import com.qiwx.pigeon.Utils.DateTimeUtils;
import com.qiwx.pigeon.Utils.StringUtil;
import com.qiwx.pigeon.adapter.home.ICageInterface;
import com.qiwx.pigeon.data.vo.CageBean;
import com.qiwx.pigeon.data.vo.CageBeanVo;

import java.util.List;

/**
 * @description
 * @Author qiwx
 * @Date 2020-04-08 11:35
 * 未下蛋鸽笼
 **/
public class WXDCagedapter extends BaseQuickAdapter<CageBeanVo, BaseViewHolder> {
    ICageInterface iCageInterface;

    public WXDCagedapter(int layoutResId, List<CageBeanVo> data) {
        super(layoutResId, data);
    }

    public void setiCageInterface(ICageInterface iCageInterface) {
        this.iCageInterface = iCageInterface;
    }

    @Override
    protected void convert(BaseViewHolder holder, CageBeanVo cageBean) {
        holder.setText(R.id.txt_c_number, "编号: " + cageBean.getNumber() + "");

        String status = DBSqlUtil.getStatusDes(cageBean.getStatus());
        holder.setText(R.id.txt_status, status);
//        long last_lay_egg_date = cageBean.getLast_laye_egg_date();
        String lay_egg_date = cageBean.getLast_lay_egg_date();
        String pd_date = cageBean.getPd_date();
        if (StringUtil.isEmpty(lay_egg_date)) {
            lay_egg_date = "- -月- -日";
        } else {
            lay_egg_date = DateTimeUtils.timeStamp2MDS(lay_egg_date);
        }
        holder.setText(R.id.txt_lay_date, "下蛋:" + lay_egg_date);

        if (StringUtil.isEmpty(pd_date)) {
            pd_date = "- -月- -日";
        } else {
            pd_date = DateTimeUtils.timeStamp2MDS(pd_date);
        }
        holder.setText(R.id.txt_pd_date, "配对:" + pd_date);


//        holder.findView(R.id.btn_opreate).setOnClickListener(v -> {
//            if (iCageInterface != null) {
//                iCageInterface.onSelectId(holder.getAdapterPosition(), cageBean.getId(), 1);
//            }
//
//        });
//        holder.findView(R.id.btn_opreation_add_date).setOnClickListener(v -> {
//            if (iCageInterface != null) {
//                iCageInterface.onSelectId(holder.getAdapterPosition(), cageBean.getId(), 2);
//            }
//        });


    }
}
